package com.jijs.service.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;

public class ClientTest {
	private IUserService port;
	private UserService us;

	public ClientTest(){
		try {
			URL url = new URL("http://localhost:9898/us/");
			QName name = new QName("http://service.jijs.com/user/", "userService");
			us = new UserService(url,name);
			port =us.getUserServicePort();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
	
	public void testList(){
		List<User> list = port.list();
		for (User user : list) {
			System.out.println(user.getNickname());
		}
	}
	
	public void testAdd(){
		User u = new User();
		u.setNickname("张三");
		u.setUsername("zhangsan");
		u.setPassword("123");
		try {
			port.add(u);
		} catch (UserException_Exception e) {
			e.printStackTrace();
		}
	}
	
	public void testLogin(){
		try {
			User u = port.login("2323", "sdsd");
			System.out.println(u.getUsername());
		} catch (UserException_Exception e) {
			e.printStackTrace();
		}
	}
	
	public void testDelete(){
		port.delete("zhangsan");
	}
	
	public static void main(String[] args) {
		ClientTest t = new ClientTest();
		t.testAdd();
		t.testList();
//		t.testLogin();
		t.testDelete();
//		t.testList();
	}
}
